<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>#{msgs.windowTitle}</title>
	<h:outputStylesheet library="css" name="Styles.css" />
</h:head>

<h:body>
	<div id="heading">
		<ui:insert name="heading">

			<p:toolbar>

				<p:toolbarGroup align="left">
					<h:form>
						<p:spacer width="15px" />
						<h:outputText value="#{msgs.windowTitle}" />
						<p:spacer width="10px" />
						<p:separator />
						<p:spacer width="10px" />
						<p:autoComplete id="search" value="#{userBean.userNameSearch}"
							completeMethod="#{userBean.autoCompleteSearch}"
							validator="#{userBean.validateUserName}" immediate="true" />
						<p:spacer width="7px" />
						<p:watermark for="search" value="#{msgs.search}" />
						<p:commandButton id="searchButton" icon="ui-icon-search"
							action="#{userBean.viewUserProfile}" ajax="false" />
					</h:form>
				</p:toolbarGroup>

				<p:toolbarGroup id="notLoggedInToolbar" align="right"
					rendered="#{userBean.NotloggedIn()}">
					<h:form>
						<p:growl id="growl" life="1500"/>
						<h:outputLabel for="userName" value="#{msgs.userName}" />
						<p:spacer width="7px" />
						<p:inputText id="userName"
							value="#{userBean.currentUser.userName}" required="true"
							requiredMessage="#{msgs.requiredUserName}"
							validator="#{userBean.validateUserName}"
							validatorMessage="#{msgs.validateUserName}">
							<f:ajax/>
						</p:inputText>
						<p:spacer width="10px" />
						<h:outputLabel for="password" value="#{msgs.password}" />
						<p:spacer width="7px" />
						<p:password id="password" value="#{userBean.currentUser.password}"
							required="true" requiredMessage="#{msgs.requiredPassword}"
							validator="#{userBean.validateUserPassword}"
							validatorMessage="#{msgs.validatePassword}">

						</p:password>
						<p:spacer width="7px" />
						<p:commandButton value="#{msgs.login}"
							action="#{userBean.verifyUser}" update="growl" ajax="false"/>
						<p:spacer width="2px" />
					</h:form>
				</p:toolbarGroup>

				<p:toolbarGroup id="loggedInToolbar" align="right"
					rendered="#{userBean.loggedIn()}">
					<h:form>
						<p:commandButton value="#{msgs.tweetStream}" action="home" ajax="false" />
						<p:commandButton value="#{msgs.profile}"
							action="#{userBean.viewOwnProfile()}" ajax="false" />
						<p:spacer width="10px" />
						<p:separator />
						<p:spacer width="10px" />
						<p:commandButton value="#{msgs.logout}" icon="ui-icon-arrowrefresh-1-w"
							action="#{userBean.logout}" ajax="false" />
						<p:spacer width="2px" />
					</h:form>
				</p:toolbarGroup>
			</p:toolbar>

			<p:spacer height="20px" />

		</ui:insert>
	</div>

</h:body>
</html>